#!/usr/bin/env python
# -*-coding:utf-8 -*-
from multiprocessing import Pool

from kernel.core import Monitor, Spider


def worker(arg):
    download = __import__('download')
    monitor = Monitor()
    monitor.get_all_subclass(download, Spider)
    monitor.start()


def main(process):
    ps = Pool(process)
    for i in range(process):
        ps.apply(worker, args=(i,))  # 同步执行
    ps.close()
    ps.join()


if __name__ == '__main__':
    main(process=2)  # 多进程启动
